package com.jian.android.autojipai.app.helper;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.os.Build;
import android.provider.Settings;

public class StringTool {
    public static String getVersionName(Context context) {
        try {
            return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
        } catch (Exception unused) {
            return null;
        }
    }

    public static long getVersionNumber(Context context) {
        try {
            PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
            if (Build.VERSION.SDK_INT >= 28) {
                return packageInfo.getLongVersionCode();
            }
            return packageInfo.versionCode;
        } catch (Exception e) {
            return 0L;
        }
    }

    public static String getAndroidId(Context context) {
        try {
            return Settings.Secure.getString(context.getContentResolver(), "android_id");
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
    }

    public static String getID() {
        try {
            return Build.ID;
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
    }

    public static String getRadioVersion() {
        try {
            return Build.getRadioVersion();
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
    }
}
